<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">TI核销原申请文件列表</h2>
</div>
<!-- 标题 -->
<div>
    <div action="" class="form-inline">
        <table class="row-margin-top tab-content table-bordered  table " border="1">
            <tr>
                <td class="font-bold" colspan="2">您选择的经销商是：{$data.title}
                    <a href="{:url('changejxs')}" class="btn btn-info" style="margin-left: 10px">点击更换经销商
                    </a></td>
            </tr>
            <tr>
                <td class="font-bold">您选择本次需核销的申请单:</td>
                <td class="text-right">
                    <label class="radio-inline">
                        <input type="radio" class="showtype" name="showtype" id="inlineRadio1" value="1" {if request()->param('showtype')==1}checked{/if}>仅显示可核销申请单
                    </label>
                    <label class="radio-inline">
                        <input type="radio" class="showtype" name="showtype" id="inlineRadio2" value="2" {if request()->param('showtype')==2||!request()->param('showtype')}checked{/if}>显示所有申请单
                    </label>
                </td>
            </tr>
        </table>
        <table class="table row-margin-top table-bordered text-center bud_hei">
            <tr class="info text-center">
                <td class="text-center" rowspan="2">序号</td>
                <td class="text-center" rowspan="2">申请单编号</td>
                <td class="text-center" rowspan="2" style="min-width: 200px;width: 200px">活动主题</td>
                <td class="text-center" rowspan="2">申请时间</td>
                <td class="text-center" rowspan="2">申请人</td>
                <td class="text-center" rowspan="2">已批准</td>
                <td class="text-center" rowspan="2">已核销</td>
                <td class="text-center" colspan="2">未核销</td>
                <td class="text-center" rowspan="2">当前可核销</td>
                <td class="text-center" rowspan="2">操作</td>
                <td class="text-center" rowspan="2"><input type="checkbox" id="checkAll" class="form-control"></td>
            </tr>
            <tr class="info text-center">
                <td>申请中</td>
                <td>未申请</td>
            </tr>
            {volist name="data.list" id="row" key="k"}
            <tr class="data">
                <td>{$k}</td>
                <td>{$row.sn}</td>
                <td>{$row.title}</td>
                <td>{:date('Y-m-d',$row.ctime)}</td>
                <td>{$row.cuser_name}</td>
                <td class="ObjectNum text-right">{$row.yipizhun}</td>
                <td class="ObjectNum text-right">{$row.yihexiao}</td>
                <td class="ObjectNum text-right">{$row.shenqingzhong}</td>
                <td class="ObjectNum text-right">{$row.weishenqing}</td>
                <td class="ObjectNum font-bold text-right">{$row.kehexiao}</td>
                <td class="font-bold">
                    <button class="btn-info btn setBtn setNoHexiao" data-id="{$row.id}">设置为不予核销</button>
                </td>
                <td>
                    {if $row.kehexiao>0}
                    <input type="checkbox" name="items" class="form-control" value="{$row.id}">
                    {/if}
                </td>
            </tr>
            {/volist}
            <tr class="trTotal text-right">
                <td colspan="5">合计：</td>
                <td class="trTotal_pz ObjectNum">{$sum1}</td>
                <td class="trTotal_verify ObjectNum">{$sum2}</td>
                <td class="trTotal_applying ObjectNum">{$sum3}</td>
                <td class="trTotal_noapply ObjectNum">{$sum4}</td>
                <td class="trTotal_allowVerify ObjectNum font-bold">{$sum5}</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td colspan="12" class="text-left">
                    核销类型：
                    <label class="radio-inline">
                        <input type="radio" name="hexiaoleixing" id="inlineRadio11" value="1">按活动整单核销
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="hexiaoleixing" id="inlineRadio22" value="0">按活动明细核销
                    </label>
                </td>
            </tr>
        </table>
        <p>注：<br>
            (1)上表金额单位："元"。<br>
            (2)此表中只体现"可核销金额>0"的申请单。<br>
            (3)"可核销金额"指的是符合公司规定的核销条件，且仍未进行核销的金额。如公司规定的未反馈、未核查、超过核销规定期限等的费用均不属于"可核销金额"的范畴。<br>
            (4)点击"设置为不予核销"则释放该申请单的"可核销金额"至预算池，该申请单不再支持核销。<br>
            (5)"可核销金额"小于"未申请金额"，则代表该申请中存在"未反馈"、"反馈中"、"未核查"或"已锁定"的情况。
        </p>
        <div class="row sub_btn" style="width:100%;text-align:center;padding: 10px 0">
            <input type="button" class="btn btn-success" id="subBtn" value="确认提交">
            <input type="button" class="btn btn-warning" value="返回" onclick="back()" style="margin-left: 20px">
        </div>
    </div>
</div>
<!-- 全局js -->
{include file="Public/footer"}
<form action="" id="form1"></form>
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<!--统计代码，可删除-->
<script>
    function back() {
        history.go(-1)
    }

    $(document).ready(function () {
        //显示类型
        $('.showtype').on('click',function () {
            var val = $(this).val()
            var url = $('#form1').attr('action')
                location.href = url+'?showtype='+val

        })
        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);

        /*确认提交*/
        $("#subBtn").click(function () {

            var val = $('input:radio[name="hexiaoleixing"]:checked').val();
            var $items = $("[name=items]:checkbox");
            if (val == null) {
                sweetAlert("", "请选择核销类型！", "warning");
            }
            else if ($items.filter(':checked').length < 1) {
                sweetAlert("", "请选择原申请文件！", "warning");
            } else {
                var tiids = []
                $items.filter(':checked').each(function (i,o) {
                    tiids.push($(o).val())
                })
                tiids = JSON.stringify(tiids)
                if(val=='0')
                    location.href='{:url("writeoff")}?hexiaoleixing='+val+'&tiids='+tiids
                else
                    location.href='{:url("writeoff2")}?tiids='+tiids //整单
                return false;
            }
        });
        /*checkbox选择*/
        $("#checkAll").click(function () {

            $("[name=items]:checkbox").prop("checked", $(this).prop("checked"));
            if ($("[name=items]:checkbox").prop("checked") != true) {
                // console.log($(this))
                $("[name=items]:checkbox").parents("tr").css("backgroundColor", "#fff")
            } else {
                $("[name=items]:checkbox").parents("tr").css("backgroundColor", "#f8f800")

            }
        })
        $("[name=items]:checkbox").click(function () {
            //定义一个临时变量，避免重复使用同一个选择器选择页面中的元素，提高程序效率
            // console.log(1)
            var $tmp = $("[name=items]:checkbox");
            if ($(this).prop("checked") != true) {
                // console.log($(this))
                $(this).parent().parent().css("backgroundColor", "#fff")
            } else {
                $(this).parent().parent().css("backgroundColor", "#f8f800")

            }
            //用filter()方法筛选出选中的复选框，并直接给CheckedAll赋值
            $("#checkAll").prop('checked', $tmp.length == $tmp.filter(':checked').length);

        })

        //设置不予核销
        $('.setNoHexiao').click(function () {
            var link = $(this).attr('href')
            var id = $(this).data('id')
            swal({
                title: "您确定设置申请单号为：xxx，活动主题为：摸摸摸的余额（未申请核销金额）为不予核销吗？如确定则释放该费用回预算池，该申请单不再支持核销！",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            }, function (isConfirm) {
                if(isConfirm){
                    $.ajax({
                        'type':'post',
                        'url':link,
                        'dataType':'json',
                        'success':function (data) {
                            if(data.success){
                                swal({
                                    title:data.msg,
                                    type:'success'
                                },function () {
                                    location.reload()
                                })
                            }else
                                swal(data.msg, "", "error");
                        }
                    })
                }

            });
            return false
        });
    })
</script>
</body>

</html>
